<? require_once('admin/dbconnect.php'); ?>
<?php require_once('admin/conf.php'); ?>

<script language="javascript"> 

function nuevoAjax(){ 
var xmlhttp=false; 
 try { 
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
 } catch (e) { 
  try { 
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
  } catch (E) { 
   xmlhttp = false; 
  } 
 } 
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
  xmlhttp = new XMLHttpRequest(); 
} 
return xmlhttp; 
} 

<?
$query=" SELECT * FROM videos ORDER BY id DESC ";
$result = mysql_query($query) or die ("Error ".mysql_error());
while($row=mysql_fetch_array($result))
{
$id=$row['id'];
?>
function cargar<? echo $id; ?>(){ 
var contenido; 
contenido = document.getElementById('contenido'); 
ajax=nuevoAjax(); 
ajax.open('GET', 'code.php?id=<? echo $id; ?>',true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
contenido.innerHTML = ajax.responseText 
} 
} 
ajax.send(null) 
}
<?
}
?>

function Open(){ 
var contenido; 
contenido = document.getElementById('contenido'); 
ajax=nuevoAjax(); 
ajax.open("GET", "open.php",true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
contenido.innerHTML = ajax.responseText 
} 
} 
ajax.send(null) 
} 

function Close(){ 
var contenido; 
contenido = document.getElementById('contenido');  
ajax=nuevoAjax(); 
ajax.open("GET", "close.php",true); 
ajax.onreadystatechange=function() { 
if (ajax.readyState==4) { 
contenido.innerHTML = ajax.responseText 
} 
} 
ajax.send(null) 
} 
</script>

<?
$starting=microtime();

require_once('include/header.php');
include "admin/youtube.class.php";
$jutjub = new YouTube();

$close=$_POST['close'];
if(!empty($close))
{
print "<font color='#ff0000'>Video Server Closed</font>";
}else{
$query="SELECT id FROM videos";
$result= mysql_query($query);
$rows=mysql_num_rows($result);

$ppp = 9; 
$nop= ceil($rows / $ppp);

echo "<center><u>$rows Videos in <font color='#ff0000'>$domain</font>  Database</u>";
echo "<br>";
echo "<font size='1'>".$time=date("D  d M Y -- H.i")." $time (Server Time)</font>";
echo "<br>";
echo "</center>";

echo "<p align='left'><font size='2'>Page : </font>";
for ($i = 1 ; $i <= $nop ; $i++){
echo "&nbsp;<a href='funny_videos.php?open=1&page=$i'><font size='2'> $i </font></a>&nbsp;";
}

if (isset($_GET['page'])){
                          $page = $_GET['page'];
                         }else{
                               $page = 1;
                              }
echo "</p>";

$start= ($page - 1) * $ppp;
?>
<div id="video_container" style="width:600px; height:500px;">
<?
$top="1";
$query=" SELECT * FROM videos ORDER BY counter DESC LIMIT $start,$ppp ";
$result = mysql_query($query) or die ("Error ".mysql_error());
while($row=mysql_fetch_array($result)){
$id=$row['id'];
$videoname=$row['videoname'];
$counter=$row['counter'];
$url=$row['videocode'];
if($top=="3"){$top="1";echo "</tr><tr>";}

$url2 = str_replace("http://in.youtube.com/watch?v=", "", $url);	

?>

<div id="youtubevideo" style="width:150px; height:150px; border:1px solid #000066; float:left; padding:3px; text-align:center;">
<span style="cursor: pointer; text-decoration: none" onClick="cargar<? echo $id; ?>()">
<a href="http://www.youtube.com/v/<? echo $url2; ?>" class="lightwindow page-options" params="lightwindow_width=425,lightwindow_height=340,lightwindow_loading_animation=false" title="YouTube: <? echo $videoname; ?>" ><? echo $jutjub->ShowImg($url,2); ?></a></span>

<a href="form.php" params="lightwindow_width=350,lightwindow_height=160" class="lightwindow page-options"><strong>Write some Comments</strong></a>
<br />
<span style="cursor: pointer; text-decoration: none" onClick="cargar<? echo $id; ?>()">
<? echo $videoname; ?></span>

<br>
<font color='#ff0000'><b><? print $counter; ?></b></font> Views
</span></div>
<?
$top++;
}
?>
<? 
}
?>
</div>
<div style="clear:both;">
<? $end=microtime(); $generated=$end-$start; ?>

Page generated in <font color='#ff0000'><? print $generated; ?></font> seconds.
</div>


<?php require_once('include/footer.php'); ?> 